#include "widget.h"
#include "ui_widget.h"

#include <QDebug>
#include <QRect>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    //禁止文本输出
    ui->plainTextEdit->setReadOnly(true);
    //设置下拉框
    ui->comboBox_1->addItem("1-1");
    ui->comboBox_1->addItem("1-2");
    ui->comboBox_1->addItem("1-3");
    ui->comboBox_2->addItem("2-1");
    ui->comboBox_2->addItem("2-2");
    ui->comboBox_2->addItem("2-3");
    ui->comboBox_3->addItem("3-1");
    ui->comboBox_3->addItem("3-2");
    ui->comboBox_3->addItem("3-3");
    //设置微调按钮
    ui->spinBox_1->setMaximum(5);
    ui->spinBox_2->setMaximum(5);
    ui->spinBox_3->setMaximum(5);
    ui->spinBox_1->setMinimum(1);
    ui->spinBox_2->setMinimum(1);
    ui->spinBox_3->setMinimum(1);
    ui->spinBox_1->setSingleStep(1);
    ui->spinBox_2->setSingleStep(1);
    ui->spinBox_3->setSingleStep(1);
    //设置旋钮
    ui->dial->setMaximum(100);
    ui->dial->setMinimum(50);
    ui->dial->setSingleStep(1);
    ui->dial->setSliderPosition(100);
    ui->dial->setNotchesVisible(true);
    ui->dial->setWrapping(true);
    //获得QRect
    QRect rect=this->geometry();
    //设置滑块
    ui->horizontalScrollBar->setMaximum(1700);
    ui->horizontalScrollBar->setMinimum(200);
    ui->horizontalScrollBar->setSingleStep(10);
    ui->horizontalScrollBar->setSliderPosition(rect.width());
    ui->verticalScrollBar->setMaximum(900);
    ui->verticalScrollBar->setMinimum(100);
    ui->verticalScrollBar->setSingleStep(10);
    ui->verticalScrollBar->setSliderPosition(rect.height());



}


Widget::~Widget()
{
    delete ui;
}


void Widget::on_dial_valueChanged(int value)
{
    qDebug()<<value;
    this->setWindowOpacity((double)value/100);
}

void Widget::on_horizontalScrollBar_valueChanged(int value)
{
    QRect rect=this->geometry();
    this->setGeometry(rect.x(),rect.y(),value,rect.height());
}

void Widget::on_verticalScrollBar_valueChanged(int value)
{
    QRect rect=this->geometry();
    this->setGeometry(rect.x(),rect.y(),rect.width(),value);
}

void Widget::on_pushButton_clicked()
{
    QString content;
    content+=ui->label_1->text()+": "+ui->comboBox_1->currentText()+"  "+QString::number(ui->spinBox_1->value())+"\n";
    content+=ui->label_2->text()+": "+ui->comboBox_2->currentText()+"  "+QString::number(ui->spinBox_2->value())+"\n";
    content+=ui->label_2->text()+": "+ui->comboBox_2->currentText()+"  "+QString::number(ui->spinBox_2->value())+"\n";

    ui->plainTextEdit->setPlainText(content);
}
